class Solution {
public:
    int secondsToRemoveOccurrences(string s)
    {
        int ans = 0;
        while (s.find("01") != string::npos)
        {
            ans++;
            int it = -1;
            while (true)
            {
                if (it == -1)
                    it = s.find("01");
                else
                    it = s.find("01", it + 2);
                if (it == string::npos)
                    break;
                s.replace(it, 2, "10");
            }
        }
        return ans;
    }
};